package com.lmx.wuzhangshao.ui

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.view.Window
import androidx.appcompat.app.AppCompatActivity
import com.lmx.wuzhangshao.MyApplication
import com.lmx.wuzhangshao.util.SharedPreUtil

/**
 * 启动页面
 *
 * @author Leung
 * @date 2020/7/23 21:09
 */
class SplashPageActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        Handler().postDelayed({
            MyApplication.getInstance().let {
                if (SharedPreUtil.getBoolean(it, "isLogin", false)) {
                    startActivity(Intent(this@SplashPageActivity, MainActivity::class.java))
                    SharedPreUtil.saveBoolean(it, "isLogin", true)
                } else {
                    startActivity(Intent(this@SplashPageActivity, LoginActivity::class.java))

                }
            }
            finish()
        }, 2000)
    }

}